<%@page import="Board.BoardMyba"%>
<%@page import="common.SerialDAO"%>
<%@page import="common.SerialDTO"%>
<%@ page language="java" contentType="text/html; charset=UTF-8"
	pageEncoding="UTF-8"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>Insert title here</title>
</head>

<script type="text/javascript">
	/* function ba(b) {

		location.href = "index.jsp?inc_content=./board/board_list.jsp&bo_part="
				+ bo_part + "&nowPage=" + 1;
	} */
	function init(part){
		location.href= "index.jsp?inc_content=./board/board_list.jsp&bo_part="
			+ part + "&nowPage=" + 1;
		
		//alert(url);
	}
	
</script>
<body>
	<jsp:useBean id="boardVo" class="Board.BoardVo" />
	<jsp:useBean id="bankVo" class = "Board.DataBank"/>
	<jsp:setProperty property="*" name="boardVo" />
	<input type = 'hidden' name = 'bo_part' value = "<%=boardVo.getBo_part()%>">
	<%
		/* System.out.println("null? : "+boardVo.getBo_part()); */
		String uploadPath;
		String mid = (String) session.getAttribute("Mid");
		String part = (String) session.getAttribute("part");

		//채번을 하기위해 클래스에 필요 변수를 저장
		SerialDTO dto = new SerialDTO("board", "bo_no", "B");
		//DB 작업 클래스 생성
		SerialDAO dao = new SerialDAO();
		
		//DB 작업클래스에 필요변수가 저장 되있는 클래스를 setter를 이용해 저장
		dao.setDto(dto);
		//채번한 결과 값을 변수에 저장
		String temp = dao.serialReturn();

		boardVo.setBo_no(temp);
		boardVo.setSa_no(mid);
		boardVo.setRequest(request);

		BoardMyba board = new BoardMyba();
		board.setUploadPath(request.getSession().getServletContext().getRealPath("/"));
		
		/* String realPath = boardVo.getRequest().getServletContext()
				.getRealPath("WebContent");
		String path = realPath.replace("\\WebContent", "");
		String pro = path.substring(path.lastIndexOf("\\") + 1, path.length());
		uploadPath = realPath.substring(0, realPath.indexOf(".")) + pro
				+ "\\WebContent\\homepage\\board\\boardData\\"; */
		
		board.setUploadPath(board.getUploadPath());
		/* bankVo.setUploadPath(board.getUploadPath()); */
		/*System.out.print("실제 경로 : "+board.getUploadPath());
		System.out.print("실제 경로2 : "+bankVo.getUploadPath());*/
		board.setVo(boardVo);
	%>
	<%
		if (board.insert()) {
			
	%>
	<script>
		init("<%=boardVo.getBo_part()%>");
	</script>

	<%
		} else {
	%>
	<h3>다시 시도해주세요.</h3>
	<%
		}
	%>

</body>
</html>